﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KCMS.DataAcsess.Interfaces;
using StructureMap;
using AutoMapper;
using KCMS.BusinessLogic.Models;
using KCMS.BusinessLogic.Interfaces;


namespace KCMS.BusinessLogic.Engine
{
    public class SizeService:ISizeService
    {
        private ISizeManager sizeManager = ObjectFactory.GetInstance<ISizeManager>();
        public Models.Size getById(Guid id)
        {
            DataAcsess.Entitys.SizeEntity sizeEntity = sizeManager.getById(id);
            return Mapper.Map<DataAcsess.Entitys.SizeEntity, Models.Size>(sizeEntity);
        }
       
        public IEnumerable<Models.Size> getAll()
        {
            var model = from t in sizeManager.getAll()
                        orderby t.Number
                        select t;
            return Mapper.Map<IEnumerable<DataAcsess.Entitys.SizeEntity>, IEnumerable<Models.Size>>(model);

        }

        public void update(Size size)
        {
            sizeManager.update(Mapper.Map<Size, DataAcsess.Entitys.SizeEntity>(size));
        }


        public void save(Size size)
        {
            sizeManager.save(Mapper.Map<Size, DataAcsess.Entitys.SizeEntity>(size));
        }


        public void delete(Guid id)
        {
            sizeManager.delete(id);
        }
    }
}
